package cn.jc.myfile.common.exception;

import cn.jc.myfile.common.entity.result.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler({cn.jc.myfile.common.exception.GlobalException.class})
    public R<cn.jc.myfile.common.exception.GlobalException> handleGlobalException(cn.jc.myfile.common.exception.GlobalException e) {
        log.error("出现异常，错误码={}，错误信息={}", e.getRCode(), e.getMessage());
        e.printStackTrace();
        R<cn.jc.myfile.common.exception.GlobalException> result = R.fail(e);
        return result;
    }
}
